package com.shrct.businessprocess.process_test.impl;

import com.shrct.businessprocess.organization.RCEmployee;
import com.shrct.businessprocess.organization.impl.RCEmployeeImpl;
import com.shrct.businessprocess.process_test.PItem;
import com.shrct.businessprocess.process_test.proxy.PItemProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("PITEM_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "pitem")
public class PItemImpl extends BaseModelObject implements PItem {
  public PItemImpl() {
    super();
  }
  
  private String itemName;
  
  public String getItemName() {
    return this.itemName;
  }
  
  public PItem setItemName(final String itemName) {
    this.itemName = itemName;
    return this;			
    
  }
  
  private Integer itemCount;
  
  public Integer getItemCount() {
    return this.itemCount;
  }
  
  public PItem setItemCount(final Integer itemCount) {
    this.itemCount = itemCount;
    return this;			
    
  }
  
  @JoinColumn(name = "saler_id")
  @ManyToOne(targetEntity = RCEmployeeImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCEmployee saler;
  
  public RCEmployee getSaler() {
    return this.saler;
  }
  
  public PItem setSaler(final RCEmployee saler) {
    this.saler = saler;
    return this;			
    
  }
  
  private Boolean isPassed = Boolean.valueOf(false);
  
  public Boolean getIsPassed() {
    return this.isPassed;
  }
  
  public PItem setIsPassed(final Boolean isPassed) {
    this.isPassed = isPassed;
    return this;			
    
  }
  
  public static PItem create(final IObjectFactory objectFactory) {
    com.shrct.businessprocess.process_test.PItem pItem = new com.shrct.businessprocess.process_test.impl.PItemImpl(
    );
    objectFactory.create(pItem);
    return pItem;			
    
  }
  
  public static PItem createPItemImpl(final IObjectFactory objectFactory, final Procedure1<PItem> init) {
    com.shrct.businessprocess.process_test.PItem pItem = new com.shrct.businessprocess.process_test.impl.PItemImpl(
    );
    objectFactory.create(pItem);
    init.apply(pItem);
    
    return pItem;			
    
  }
  
  public PItemProxy toProxy() {
    com.shrct.businessprocess.process_test.proxy.PItemProxy proxy = new com.shrct.businessprocess.process_test.proxy.PItemProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
